import Vue from "vue";
import Router from "vue-router";
import Layout from "@/components/layout/layout";

Vue.use(Router);

export default new Router({
  base: process.env.VUE_APP_BASE_URL,
  // mode: 'history', history模式会出现很多未知的问题
  routes: [
    {
      path: "",
      redirect: "/home"
    },
    {
      path: "/login",
      name: "login",
      component: function(resolve) {
        require(["@/views/login/login.vue"], resolve);
      }
    },
    {
      path: "/",
      component: Layout,
      children: [
        {
          path: "/home",
          name: "home",
          component: function(resolve) {
            require(["@/views/home/home.vue"], resolve);
          },
          meta: {
            openKey: "management",
            selectedKey: "home"
          }
        }
      ]
    }
  ]
});
